<template>
    <div>
        <Drawer title="经营数据" v-model="drawer" width="918" :styles="styles">
            <Table size="small" ref="table" :columns="columns" :data="tdata" :loading="loading">
                <template slot-scope="{ row }" slot="name">
                    <span>{{row.name}}{{' ' + row.gender + ' '}}{{row.age}}岁</span>
                </template>
            </Table>
            <div class="ivu-mt ivu-text-center">
                <Page
                    :total="total"
                    :current.sync="ruleForm.page"
                    show-total
                    show-elevator
                    :page-size="ruleForm.pageSize"
                    @on-change="changePage"
                    :page-size-opts="pageOpts"
                    show-sizer transfer
                    @on-page-size-change="changePageSize"
                />
            </div>
        </Drawer>
    </div>
</template>

<script>
    import mixins from '@/utils/mixins'
    import { getManagementDetail } from '@/api/report'
    export default {
        name: 'table-list',
        mixins: [mixins],
        data () {
            return {
                tdata: [],
                loading: false,
                drawer: false,
                columns: [
                    {
                        title: '基本信息',
                        slot: 'name',
                        minWidth: 119
                    },
                    {
                        title: '病种',
                        key: 'diseases_name',
                        minWidth: 80
                    },
                    {
                        title: '诊疗号',
                        key: 'patient_card_id',
                        minWidth: 90
                    },
                    {
                        title: '挂号时间',
                        key: 'reg_time',
                        minWidth: 125
                    },
                    {
                        title: '上次复诊时间',
                        key: 'last_revisiting_time',
                        minWidth: 125
                    },
                    {
                        title: '未到天数',
                        key: 'missed_days',
                        minWidth: 100
                    },
                    {
                        title: '下次复诊时间',
                        key: 'next_revisiting_time',
                        minWidth: 125
                    },
                    {
                        title: '总回访次数',
                        key: 'count_follow',
                        minWidth: 118
                    },
                    {
                        title: '回访次数​',
                        key: 'callback_count_month',
                        minWidth: 118
                    }
                ],
                ruleForm: {
                    page: 1,
                    pageSize: 10
                },
                pageOpts: [10, 20, 30, 50],
                styles: {
                    height: 'calc(100% - 55px)',
                    overflow: 'auto',
                    paddingBottom: '53px',
                    position: 'static'
                },
                createForm: {}
            }
        },
        methods: {
            getConfigs () {
                return {
                    start_time: this.createForm.start_time,
                    end_time: this.createForm.end_time,
                    data_type: this.createForm.data_type,
                    member_id: this.createForm.member_id,
                    profession_id: this.createForm.profession_id,
                    page: this.ruleForm.page,
                    pageSize: this.ruleForm.pageSize
                }
            },
            onLoad () {
                this.loading = true
                const config = this.getConfigs()
                getManagementDetail(config).then(res => {
                    this.total = res.total
                    this.tdata = res.list || []
                }).finally(() => {
                    this.$nextTick(() => {
                        this.loading = false
                    })
                })
            },
            handleDrawer (row) {
                this.drawer = true
                this.tdata = []
                this.createForm = row
                this.ruleForm.page = 1
                this.onLoad()
            }
        }
    }
</script>

<style scoped>

</style>
